<!DOCTYPE html>
<html>
<head>
    <title>参数配置管理</title>
<#include "../common/common.ftl"/>
    <link rel="stylesheet" href="/modules/formSelects/formSelects-v4.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row  layui-col-space10">
        <div class="layui-col-xs12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" id="searchForm">
                        参数配置名称：
                        <div class="layui-inline" style="width: 120px;">
                            <input class="layui-input" name="search_like_string_p.name" autocomplete="off">
                        </div>
                        <button class="layui-btn" type="button" id="searchButton"><i
                                class="layui-icon layui-icon-search"></i>搜索
                        </button>
                    </form>
                    <table id="dataTable" class="layui-table" lay-filter="layFilter"></table>
                    <!--序号-->
                    <script type="text/html" id="indexTpl">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                    <!--菜单-->
                    <script type="text/html" id="dataTable_toolbar">
                        <a class="layui-btn layui-btn-xs jmdf-btn-edit" lay-event="dataTable_operate"><i
                                class="layui-icon layui-icon-edit"></i>参数配置</a>
                        <a class="layui-btn layui-btn-xs jmdf-btn-delete" lay-event="dataTable_delete"><i
                                class="layui-icon layui-icon-delete"></i>删除</a>
                    </script>
                    <!-- 表格头部工具栏 -->
                    <script type="text/html" id="toolbar">
                        <div class="layui-btn-container right">
                            <button lay-event="reload" class="layui-btn layui-btn-sm"><i
                                    class="layui-icon layui-icon-refresh"></i>重载
                            </button>
                            <button lay-event="add" class="layui-btn layui-btn-sm"><i
                                    class="layui-icon layui-icon-add-circle"></i>新增
                            </button>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['table', 'form', 'jmdf', 'page', 'dataDict'], function () {
        var jmdf = layui.jmdf, page = layui.page, table = layui.table, form = layui.form, $ = layui.jquery, dataDict = layui.dataDict;

        form.render();

        /***********************table表格相关操作 start*************************/
        var tableRenderId = "renderId";
        var tableId = "dataTable";
        var table_layFilter = "layFilter";

        var tableUrl = "loadParameterList";
        //列项内容
        var cols = [[
            {title: "序号", fixed: 'left', type: 'numbers', toolbar: '#indexTpl', align: 'center', width: 60}
            , {field: "id", title: "参数配置ID", align: 'center', minWidth: 240}
            , {field: "name", title: "参数名称", align: 'center', minWidth: 240}
            , {field: "memo", title: "备注", align: 'center', minWidth: 200}
            , {title: '操作', fixed: 'right', align: 'center', width: 500, toolbar: '#dataTable_toolbar'}
        ]];

        //table设置项
        var options = {
            elem: '#' + tableId//table列表id值
            , url: tableUrl
            , toolbar: '#toolbar'//自定义工具栏
            , cols: cols
            , id: tableRenderId
            , defaultToolbar: ['filter', 'print']//显示列、打印
            , autoSort: false //禁用前端自动排序。
        };
        //初始表格（含分页设置）
        page.render(options);
        //表格排序
        page.sort(tableId, tableRenderId);

        //刷新当前页方法封装
        page.reload();
        //分页查询（查询条件）
        $("#searchButton").click(function () {
            page.search("searchForm", tableRenderId);
        });
        //头工具栏事件
        table.on('toolbar(' + table_layFilter + ')', function (obj) {
            switch (obj.event) {
                case 'reload':
                    loadData();
                    break;
                case 'add':
                    jmdf.form("dataForm", "75");
                    break;
            }
        });


        table.on("tool(" + table_layFilter + ")", function (obj) {
            var data = obj.data;///获得当前行数据
            var layEvent = obj.event;//获得lay-event对应的值
            var id = data["id"];
            if (layEvent == "dataTable_operate") {
                jmdf.form("dataForm?parameterId=" + id, "60");
            } else if (layEvent == "dataTable_delete") {
                jmdf.del("delParameterById?parameterId=" + id);
            }
        });
    });
</script>
</body>
</html>